
#include "decl.h"

Obj*
cons (Obj *a, Obj *b)
{
	Cons *c = malloc (sizeof (Cons));
	Obj  *o = newObj ();
	c->a = a;
	c->b = b == Elist ? nil : b;
	o->t = TList;
	o->u.p = c;
	return o;
}

Obj*
car (Obj *o)
{
    if (o && o->t == TList)
	    return ((Cons*)(o->u.p))->a;
    return o;
}

Obj*
cdr (Obj *o)
{
    if (o && o->t == TList)
        return ((Cons*)(o->u.p))->b;
    return o;
}

